﻿using DevExpress.XtraGrid.Demos.util;
using DXApplicationTangche.DTO;
using mendian;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DXApplicationTangche.UC.订单一览新.对账.Service
{
    public class 对账Service
    {
        /// <summary>
        /// 获取每天销售现金账一览
        /// </summary>
        /// <param name="orderDate"></param>
        /// <returns></returns>
        public static List<SalePaymentReconciliationDTO> getDailySalePaymentReconciliation(String orderDate)
        {
            return
                FunctionHelper.JsonDeserialization<List<SalePaymentReconciliationDTO>>(
                    RestCall.httpGetMethod(
                        URL.接口url + "/saleConfirm/getDailySalePaymentReconciliation?orderDate=" + orderDate
                        )
                    );
        }
        /// <summary>
        /// 保存销售订单支付方式
        /// </summary>
        /// <param name="paymentType"></param>
        /// <param name="saleConfirmIds"></param>
        /// <returns></returns>
        public static String savePaymentType(String paymentType, List<String> saleConfirmIds)
        {
            return
                    RestCall.PostHttp(
                        URL.接口url + "/saleConfirm/savePaymentType?paymentType=" + paymentType,
                        FunctionHelper.JsonSerialization(saleConfirmIds)

                        );
        }
    }
    public class SalePaymentTypeConsts
    {
        public const String QUANMINFU = "全民付";    //  银联全民付
        public const String BOCPOS = "中银智慧付";    //  中银智慧付POS机
        public const String ABCPOS = "农行POS";    //  中银智慧付POS机
        public const String CURRENCY = "现金支付";   //  现金支付
        public const String ACCOUNTPAY = "账户余额支付";   //  账户余额支付
        public const String UNCONFIRMPAY = "待确认支付";   //  待确认支付
    }
    /// <summary>
    /// 销售对账DTO
    /// </summary>
    public class SalePaymentReconciliationDTO
    {
        //  客户信息和收款信息
        public String mobile { get; set; }     //	电话
        public String customerName { get; set; }     //	客户姓名
        public String addressProvince { get; set; }     //	省
        public String addressCity { get; set; }    //	市
        public String addressDistrict { get; set; }    //	区
        public String addressDetail { get; set; }    //	详细地址
        //  付款总额
        public Double totalPayment { get; set; }
        //  进项
        public Double quanminfuPayment { get; set; }   //  银联全民付
        public Double bocposPayment { get; set; }  //  中银智慧付POS机
        public Double abcposPayment { get; set; }  //  农行POS机
        public Double currencyPayment { get; set; }//  现金支付
        public Double accountpayPayment { get; set; }  //  账户余额支付
        public Double unConfirmPayment { get; set; }   //  待确认支付方式，前台如果不为空标红
        //  销项
        public Double quanminfuPaymentOut { get; set; }    //  银联全民付
        public Double bocposPaymentOut { get; set; } //  中银智慧付POS机
        public Double abcposPaymentOut { get; set; } //  农行POS机
        public Double currencyPaymentOut { get; set; }//  现金支付
        public Double accountpayPaymentOut { get; set; }  //  账户余额支付
        public Double unConfirmPaymentOut { get; set; }   //  待确认支付方式，前台如果不为空标红
        /*
        *  明细
        */
        //  进项
        public List<SalePaymentDetailDTO> quanminfuPaymentSalePaymentDetailDTOS { get; set; } = new List<SalePaymentDetailDTO>();   //  银联全民付
        public List<SalePaymentDetailDTO> bocposPaymentSalePaymentDetailDTOS { get; set; } = new List<SalePaymentDetailDTO>();    //  中银智慧付POS机
        public List<SalePaymentDetailDTO> abcposPaymentSalePaymentDetailDTOS { get; set; } = new List<SalePaymentDetailDTO>();    //  农行POS机
        public List<SalePaymentDetailDTO> currencyPaymentSalePaymentDetailDTOS { get; set; } = new List<SalePaymentDetailDTO>();  //  现金支付
        public List<SalePaymentDetailDTO> accountpayPaymentSalePaymentDetailDTOS { get; set; } = new List<SalePaymentDetailDTO>();   //  账户余额支付
        public List<SalePaymentDetailDTO> unConfirmPaymentSalePaymentDetailDTOS { get; set; } = new List<SalePaymentDetailDTO>();     //  待确认支付方式，前台如果不为空标红
        //  销项
        public List<SalePaymentDetailDTO> quanminfuPaymentOutSalePaymentDetailDTOS { get; set; } = new List<SalePaymentDetailDTO>();     //  银联全民付
        public List<SalePaymentDetailDTO> bocposPaymentOutSalePaymentDetailDTOS { get; set; } = new List<SalePaymentDetailDTO>();    //  中银智慧付POS机
        public List<SalePaymentDetailDTO> abcposPaymentOutSalePaymentDetailDTOS { get; set; } = new List<SalePaymentDetailDTO>();   //  农行POS机
        public List<SalePaymentDetailDTO> currencyPaymentOutSalePaymentDetailDTOS { get; set; } = new List<SalePaymentDetailDTO>(); //  现金支付
        public List<SalePaymentDetailDTO> accountpayPaymentOutSalePaymentDetailDTOS { get; set; } = new List<SalePaymentDetailDTO>();   //  账户余额支付
        public List<SalePaymentDetailDTO> unConfirmPaymentOutSalePaymentDetailDTOS { get; set; } = new List<SalePaymentDetailDTO>();     //  待确认支付方式，前台如果不为空标红
        public SalePaymentReconciliationDTO()
        {

        }
    }
    /// <summary>
    /// 销售订单支付DTO
    /// </summary>
    public class SalePaymentDetailDTO
    {
        public String id { get; set; }    //
        public String orderDate { get; set; }    // 日期
        public String store { get; set; }    // 销售组织
        public String assistant { get; set; }    // 主销售
        public String businessType { get; set; }    //  业务类型    top.toptimus.constValue.SalesTypeConsts
        public String paymentType { get; set; }    // 支付方式
        public String sales { get; set; }    // 辅销售
        public String barcode { get; set; }    // 成衣码
        public String styleNameCn { get; set; }    // 款式
        public String materialCode { get; set; }    //  面料
        public String styleSizeCd { get; set; }    // 尺码
        public int quantity { get; set; }    // 数量
        public Double salePrice { get; set; }    // 样衣登记价格
        public Double totalPrice { get; set; }    //  订单金额
        public Double adjustPrice { get; set; }    // 商品调价
        public Double designPrice { get; set; }    // 设计费
        public Double actualPay { get; set; }    // 实际付款
        public String mobile { get; set; }    //  电话
        public String customerName { get; set; }    //  客户姓名
        public String addressProvince { get; set; }    // 省
        public String addressCity { get; set; }    // 市
        public String addressDistrict { get; set; }    // 区
        public String addressDetail { get; set; }    // 详细地址
        public Boolean paymentConfirm { get; set; } //  是否销售确认
        public DateTime createDate { get; set; }    //  销售支付确认时间
        public String salePaymentType { get; set; } //  支付方式 
        public String inOutputType { get; set; } //  进项或销项 
        public String salePaymentDetailType { get; set; } //  销售订单支付项 
        public SalePaymentDetailDTO()
        {

        }
        public SalePaymentDetailDTO build(String inOutputType, String salePaymentDetailType)
        {
            this.inOutputType = inOutputType;
            this.salePaymentDetailType = salePaymentDetailType;
            return this;
        }
    }
}
